
var vm = new Vue({
    el : "#sxkSjList",
    data : {
        alls : [],
        colors :[],
        products : []
    },
    init:function(){
        var _self = this;
        this.$nextTick(function() {
            this.$http.post("../../sxkSjList/selectAllList",{},{emulateJSON: true}).then(function(res){
                if(res.ok){
                    _self.alls = res.body.AllLists;
                    _self.colors = res.body.ColorLists;
                    _self.products = res.body.ProductLists;
                }
                layui.use(['form'], function(){
                    var form = layui.form;


                });
            });
        });

    },
    methods: {
        saveProductionData:function(event){
            var _self = this;

            var EQId = $('#EQId option:selected').val();        //机台
            var PRODUCTID = $('#PRODUCTID option:selected').val();        //物料
            var COLORID = $('#COLORID option:selected').val();        //颜色
            var qtys = document.getElementById("qtys").value;		 //数量


            if(EQId == null || EQId== ""){
                layer.msg("机台不能为空!");
                return;
            }

            if( PRODUCTID == null || PRODUCTID == ""){
                layer.msg("纱线不能为空!");
                return;
            }

            if( COLORID == null  || COLORID == ""){
                layer.msg("颜色不能为空!");
                return;
            }

            if(  qtys == null || qtys == ""){
                layer.msg("数量不能为空!");
                return;
            }

            var data ={
                EQId : EQId,
                PRODUCTID : PRODUCTID,
                COLORID : COLORID,
                qtys : qtys,
            };

            this.$nextTick(function() {
                this.$http.post("../../sxkSjList/savePlanLists",data,{emulateJSON: true}).then(function(res){
                    if(res.ok){
                        _self.result = res.body.results;

                        if(_self.result == "false"){
                            layer.msg("处理失败");
                        }else{
                            if( res.body.QTYS == "false"){
                                layer.msg("该颜色纱线库存不足！！");
                            }else{
                                layer.msg("处理成功");
                                window.setTimeout(function() {
                                    window.location.reload();
                                }, 1000);
                            }

                        }
                    }else{
                        layer.msg("上架失败");
                    }
                });
            });
        },
        reset:function(data){
            window.location.reload();
        },
        vueAlert:function(msg){
            layui.use(['form'], function(){
                var layer = layui.layer;
                layer.msg(msg,{icon:6,time:2000});
            });
        }/*,
        renderTable: function(_self,data){
            layui.use(['form','table','laydate'], function(){
                _self.table = layui.table;
                var form = layui.form;

                _self.table.render({
                    elem: '#sxkSjListTable',
                    width: 'full-20',
                    height: 'full-150',
                    cols: [[ //标题栏
                        { field: 'WLNAME', title: '物料名称',width: 200},
                        { field: 'YSNAME', title: '颜色',width: 200},
                        /!*{field: 'YSNAME', title: '颜色',width: 200, align:'center', templet: function() {

                                $.ajax({
                                    url: "../../sxkSjList/selectColorLists",
                                    type: 'POST',
                                    async: false,
                                    data: {
                                    },
                                    dataType: 'json',
                                    success: function(data) {
                                        if(data.result){
                                            _self.tableList = data.ColorLists;

                                        }else{
                                            layer.msg("处理失败");
                                        }
                                    }
                                });

                            return _self.tableList;
                        }},*!/
                        {field: 'QTY', title: '上架数量', minWidth: 200,align:'center',edit: 'text'},
                        {field: 'DWNAME', title: '单位', minWidth: 200,align:'center'}
                    ]],
                    data:data,
                    page: true, //是否显示分页
                    limits: [10, 20, 50],
                    limit: 15 //每页默认显示的数量
                });
            });
        }*/
    }
});